home *** CD-ROM | disk | FTP | other *** search
/ Mac OS on the PowerPC Mic…rocessor - In Store Demo / Mac OS on the PowerPC Microprocessor.iso / MacOS / MacOS.dxr / 00088_Index_grid_script.ls < prev    next >
Encoding:
Text File  |  1996-05-13  |  6.0 KB  |  143 lines

  1. property iOriginX, iOriginY, iButtonSize, iButtonArea, iButtonAreaRect, iOffsetLeft, iOffsetTop, iButtonRectList, iButtonOrigin, iPreviousSelectedKeyword, iCast, iSprite
  2. global theSparkle, theBlitPict, objIndexBtn, objBookmark, gallchapterlist, gIndexParagraphField, gGraphicPath, gFileName, gSpriteSetList, gNextPlay, gQuick, gKeywordDataList, gSelLine
  3.  
  4. on birth me
  5.   set iButtonSize to 12
  6.   set tMaxH to 27
  7.   set tMaxV to 23
  8.   set iOriginX to 151
  9.   set iOriginY to 114
  10.   set iButtonArea to iOriginX & "," & iOriginY & "," & iOriginX + (iButtonSize * tMaxH) & "," & iOriginY + (iButtonSize * tMaxV)
  11.   set iButtonAreaRect to BoxToRect(iButtonArea)
  12.   set iOffsetLeft to iOriginX - iButtonSize
  13.   set iOffsetTop to iOriginY - iButtonSize
  14.   set iButtonOrigin to rect(iOffsetLeft, iOffsetTop, iOriginX, iOriginY)
  15.   set pictfilepath to gGraphicPath & getProp(gFileName, #INDEXBTN)
  16.   blitPictInitFile(objIndexBtn, pictfilepath)
  17.   set iButtonRectList to [:]
  18.   addProp(iButtonRectList, #NORMAL, "0,0,12,12")
  19.   addProp(iButtonRectList, #VISITED, "324,0,336,12")
  20.   addProp(iButtonRectList, #NORMAL_SELECTED, "336,0,348,12")
  21.   addProp(iButtonRectList, #VISITED_SELECTED, "348,0,360,12")
  22.   addProp(iButtonRectList, #MARKED, "360,0,372,12")
  23.   addProp(iButtonRectList, #VISITED_MARKED, "372,0,384,12")
  24.   addProp(iButtonRectList, #MARKED_SELECTED, "384,0,396,12")
  25.   addProp(iButtonRectList, #VISITED_MARKED_SELECTED, "396,0,408,12")
  26.   set iPreviousSelectedKeyword to gSelLine
  27.   set iCast to the number of cast "index_paragraph_name_field"
  28.   put EMPTY into field iCast
  29.   set the text of cast iCast to "."
  30.   set the textFont of cast iCast to returnFont(item 2 of gIndexParagraphField)
  31.   set the textSize of cast iCast to integer(item 3 of gIndexParagraphField)
  32.   set the textHeight of cast iCast to integer(item 4 of gIndexParagraphField)
  33.   set the textStyle of cast iCast to item 5 of gIndexParagraphField
  34.   set the textAlign of cast iCast to item 6 of gIndexParagraphField
  35.   set trect to BoxToRect(item 7 to 10 of gIndexParagraphField)
  36.   set the rect of cast iCast to trect
  37.   set the foreColor of cast iCast to returnRGB(integer(item 11 of gIndexParagraphField))
  38.   set iSprite to 38
  39.   set the puppet of sprite iSprite to 1
  40.   set the castNum of sprite iSprite to iCast
  41.   set the rect of sprite iSprite to trect
  42.   return me
  43. end
  44.  
  45. on mStartIndex me
  46.   repeat with tChapter = 1 to mGetMaxChapter(objBookmark)
  47.     set tMaxParagraphs to mGetMaxParagraph(objBookmark, tChapter)
  48.     mDrawNormalButtons(me, tChapter, tMaxParagraphs)
  49.     repeat with tParagraph = 1 to tMaxParagraphs
  50.       set tButtonStatus to mGetStatus(objBookmark, tChapter, tParagraph)
  51.       if tButtonStatus <> #NORMAL then
  52.         mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  53.       end if
  54.     end repeat
  55.   end repeat
  56. end
  57.  
  58. on mDrawNormalButtons me, tChapterLine, tMaxParagraphs
  59.   set tSrcRect to BoxToRect("0,0," & iButtonSize * tMaxParagraphs & "," & iButtonSize)
  60.   set tDestRect to RectToBox(offset(tSrcRect, iOriginX, iOffsetTop + (tChapterLine * iButtonSize)))
  61.   blitPictDrawScreen(objIndexBtn, RectToBox(tSrcRect), tDestRect, "copy", 0, 0)
  62. end
  63.  
  64. on mDrawButton me, tChapter, tParagraph, tButtonStatus
  65.   set tSrcRect to getaProp(iButtonRectList, tButtonStatus)
  66.   set tDestRect to RectToBox(offset(iButtonOrigin, tParagraph * iButtonSize, tChapter * iButtonSize))
  67.   blitPictDrawScreen(objIndexBtn, tSrcRect, tDestRect, "copy", 0, 0)
  68. end
  69.  
  70. on mDrawKeywords me, tSelectedKeyword
  71.   if iPreviousSelectedKeyword > 0 then
  72.     repeat with keywordData in getAt(gKeywordDataList, iPreviousSelectedKeyword)
  73.       set tChapter to getAt(keywordData, 1)
  74.       set tParagraph to getAt(keywordData, 2)
  75.       set tButtonStatus to mGetStatus(objBookmark, tChapter, tParagraph)
  76.       mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  77.     end repeat
  78.   end if
  79.   set iPreviousSelectedKeyword to tSelectedKeyword
  80.   repeat with keywordData in getAt(gKeywordDataList, tSelectedKeyword)
  81.     set tChapter to getAt(keywordData, 1)
  82.     set tParagraph to getAt(keywordData, 2)
  83.     set tButtonStatus to value("#" & mGetStatus(objBookmark, tChapter, tParagraph) & "_SELECTED")
  84.     mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  85.   end repeat
  86. end
  87.  
  88. on mMouseUp me
  89.   set tParagraph to (getAt(clickLoc(), 1) - iOffsetLeft) / iButtonSize
  90.   set tChapter to (getAt(clickLoc(), 2) - iOffsetTop) / iButtonSize
  91.   if (tChapter > 0) and (tParagraph > 0) and (tChapter <= mGetMaxChapter(objBookmark)) then
  92.     if tParagraph <= mGetMaxParagraph(objBookmark, tChapter) then
  93.       if the optionDown then
  94.         mSetBookMark(objBookmark, tChapter, tParagraph)
  95.         set tButtonStatus to mGetStatus(objBookmark, tChapter, tParagraph)
  96.         if gSelLine > 0 then
  97.           set tThisParagraph to [tChapter, tParagraph]
  98.           repeat with keywordData in getAt(gKeywordDataList, gSelLine)
  99.             if tThisParagraph = keywordData then
  100.               set tButtonStatus to value("#" & tButtonStatus & "_SELECTED")
  101.             end if
  102.           end repeat
  103.         end if
  104.         mDrawButton(me, tChapter, tParagraph, tButtonStatus)
  105.       else
  106.         sparkle(theSparkle, clickLoc())
  107.         repeat with tSprite in getAt(gSpriteSetList, 3)
  108.           set the visible of sprite tSprite to 0
  109.         end repeat
  110.         if gQuick then
  111.           set gNextPlay to [tChapter, tParagraph, #play]
  112.         else
  113.           set gNextPlay to [tChapter, tParagraph, #pause]
  114.         end if
  115.         set the mouseDownScript to "playerMouseDownScript"
  116.         go("PlayMode")
  117.       end if
  118.     else
  119.       beep()
  120.     end if
  121.   else
  122.     beep()
  123.   end if
  124. end
  125.  
  126. on mRollOver me
  127.   if inside(point(mouseH(), mouseV()), iButtonAreaRect) then
  128.     set tParagraph to (mouseH() - iOffsetLeft) / iButtonSize
  129.     set tChapter to (mouseV() - iOffsetTop) / iButtonSize
  130.     if (tChapter > 0) and (tParagraph > 0) and (tChapter <= mGetMaxChapter(objBookmark)) then
  131.       if tParagraph <= mGetMaxParagraph(objBookmark, tChapter) then
  132.         set the text of cast iCast to getAt(getAt(getAt(gallchapterlist, tChapter), tParagraph), 1)
  133.       else
  134.         set the text of cast iCast to " "
  135.       end if
  136.     else
  137.       set the text of cast iCast to " "
  138.     end if
  139.   else
  140.     set the text of cast iCast to " "
  141.   end if
  142. end
  143.